home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Question on argv
- Date: 10 Feb 1996 23:02:09 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb10160209@qcd.lanl.gov>
- References: <4eoq3c$45j@usenet.ucs.indiana.edu> <harmon.823153381@pegasus.montclair.edu>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: harmon@pegasus.montclair.edu's message of 1 Feb 1996 00:55:15 -0500
-
- In article <harmon.823153381@pegasus.montclair.edu>
- harmon@pegasus.montclair.edu (Derek Harmon) writes:
- <snip: I didn't read the rest: so do not know what is being attempted here>
-
- #ifdef BIG_ENDIAN
- argv[0] = hiBYTE(i);
- argv[1] = loBYTE(i);
- #else
- argv[0] = loBYTE(i);
- argv[1] = hiBYTE(i);
- #endif
-
- /* when printing, typecast argv[4] as a (int *). any reference to it */
- /* as a string hereafter will be erroneous and possibly (if < 10) fatal */
-
- printf("argv[4] = %d\n", (int *)argv[4]);
-
- This is wrong in any case %d expects an int, not an int* ... probably
- what was meant was either *(int*)argv[4] or (int)argv[4]. Note that in
- the former case, there is no guarantee that argv[4] is suitably
- aligned for being cast to (int*).
-
- There are other serious problems: nothing guarantees that the elements
- of the argv `array' can be modified. argv itself (because it is a
- local variable in main), and the strings pointed to by the elements of
- argv are modifiable (i.e. argv = ... is okay, *argv[4] = ... is okay,
- but argv[4] = ... may not be allowed.)
-
- Cheers
- Tanmoy--
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-